<?php

/*
 * It is used to register the email subscription 
 * Getting data from ajax
 * 
 */
$pathinfo = pathinfo(__FILE__);
preg_match('/.+(?=wp-content)/', $pathinfo['dirname'], $match);
$pathNeeded = preg_replace('/\ /', '/', $match[0]);
require_once($pathNeeded . 'wp-load.php'); //refer to wp-load to use instruction

global $wpdb;
if (isset($_POST['email-subscriber']) && $_POST['email-subscriber']) {
    if (filter_var($_POST['email-subscriber'], FILTER_VALIDATE_EMAIL)) {
	$wpdb->query('INSERT INTO travel_eemail_newsletter_sub(`eemail_name_sub`, `eemail_email_sub`, `eemail_status_sub`,`eemail_date_sub`) 
	VALUES("NO NAME","' . $_POST['email-subscriber'] . '","YES", "' . date('Y-m-d', time()) . '")');
	//echo 'success;Good day!<br/><br/>Thanks for your interest in receiving our Global Synergy Newsletter!  Your email address will be added to our list to receive upcoming issues!  Stay tuned and stay ENGAGED!<br/><br/>Regards,<br/>Global Synergy';
	echo 'success;Subscribed successfully';
    } else {
	echo "error;Please give us a valid email.";
    }
} else {
    echo "error;Email can not be blank.";
}
